﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Clandestine.Conversations
{
    public class DelegatePart : ConversationPart
    {
        public string DelegateName = string.Empty;

        public override void Do()
        {
            if (WorldMap.Level.Delegates.ContainsKey(DelegateName))
                WorldMap.Level.Delegates[DelegateName]();
            else
                Log.e("DelegatePart: Tried to call delegate \"{0}\" but no such delegate was found in WorldMap.Level.", DelegateName);
        }

        public override List<ConversationPart> ParseXML(XmlTextReader xml)
        {
            this.DelegateName = xml.GetAttribute("call");
            return new List<ConversationPart>() { this };
        }
    }
}
